//
//  tstDrawCard.c
//  dominion
//
//  Created by Doug Mason on 3/8/14.
//  Copyright (c) 2014 Doug Mason. All rights reserved.
//

#include <stdio.h>
#include "tstDrawCard.h"
int tstDrawCard(int player, struct gameState* state){
    int hand_count;
    int deck_count;
    int pre_hand = state->handCount[player];
    if(state->deckCount[player]<=0){
        int pre_count = state->discardCount[player];
        int  draw_result = drawCard(player,state);
        if ((state->deckCount!= pre_count-1) && (state->discardCount==0)) {
            printf("Test failed to correctly shuffle discard back into deck when deck is empty\n");
            return -1;
        }
        //Need to make sure unless there are no cards in the deck, that the player always gets a card back.
        if((state->handCount[player]!= (pre_hand+1)) && state->deckCount!=0){
            printf("failed to correctly draw a card.\n");
            return -1;
        }
        else{
            return 0;
        }
    }
    else{
        int  draw_result = drawCard(player,state);
        //Need to make sure unless there are no cards in the deck, that the player always gets a card back.
        if((state->handCount[player]!= (pre_hand+1)) && state->deckCount!=0){
            printf("failed to correctly draw a card.\n");
            return -1;
        }
        else{
            return 0;
        }
    }
}